import '../index.css'
import './print.js'

console.log('index.js文件被加载了~');


function add(x, y) {
  return x + y;
}

console.log(add(1, 6));

// 注册serviceWorker
// 处理兼容性问题
if ('serviceWorker' in navigator) {
  // 初始化注册文件
  // service-worker.js 是 Service Worker 文件，workbox-xxxx.js 是 service-worker.js 引用的文件
  window.addEventListener('load', () => {
    // 注册地址为打包后的文件地址
    navigator.serviceWorker.register('/service-worker.js').then(registration => {
      console.log('SW registered: ', registration);
    }).catch(registrationError => {
      console.log('SW registration failed: ', registrationError);
    });
  });
}